﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UtilZ.Dotnet.Ex.Base
{
    /// <summary>
    /// Array辅助类
    /// </summary>
    public class ArrayEx
    {

        private static int? _maxLength = null;
        /// <summary>
        /// 获取或设置僵尸数组最大长度
        /// </summary>
        public static int MaxLength
        {
            get
            {
                if (_maxLength.HasValue)
                {
                    return _maxLength.Value;
                }
                else
                {
#if CORE
                    //2147483591
                    return Array.MaxLength;
#else
                    //6亿,此值是尝试出来的一个比较靠谱的值,以实际可用
                    return 600000000;
#endif
                }
            }
            set
            {
                if (value <= 0)
                {
                    throw new ArgumentOutOfRangeException("数组最大长度必须大于0");
                }

                _maxLength = value;
            }
        }
    }
}
